{% extends "base.html" %}

{% block title %}Seznam ocen{% endblock %}

{% block js %}
<script type="text/javascript" src="{{ MEDIA_URL }}js/search.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  search_setcb('student',function(student){
    url = '{% url list_grades %}' + student.pk + '/';
    document.location = url;
  });
  
  {% if subjects %}
  $('select#subjects').change(function(e) {
    var value = $(e.target).val();
    if (value != 'null')
      window.location.href = '{% url list_grades student.pk %}' + value + '/';
  });
  {% endif %}
});
</script>
{% endblock %}

{% block content %}
{% if not student %}
{% include "snippets/student/search.htm" %}
{% else %}
<div class="ro_form">
<p>
<button onclick="window.location.href='{% url list_grades %}';">Izberi novega študenta</button>
{% endif %}

{% if subjects %}
<label for="subjects">Izberi predmet:</a>
<select id="subjects">
  <option value="null">---</option>
{% for s in subjects %}
  <option value="{{ s.pk }}"{% if s == subject %} selected="true"{% endif %}>{{ s }}</option>
{% endfor %}
</select>
{% else %}
{% if student %}
<br />Študent <b>{{ student }}</b> pri vas ni poslušal nobenega predmeta.
{% endif %}
{% endif %}
{% if student %}
</p>
</div>
{% endif %}

{% if grades != None %}
<br />
<br />

Trenutno izbran študent: <b>{{ student }}</b> pri predmetu <b>{{ subject }}</b>
<table class="list" width="100%">
  <thead>
    <tr>
      <th>Datum roka</th>
      <th>Točke na izpitu</th>
      <th>Ostale točke</th>
      <th>Ocena</th>
    </tr>
  </thead>
  <tbody>
{% for application in grades %}
    <tr>
      <td>{{ application.exam.date }}</td>
      {% if application.exam_grade == 0 %}
      <td style="text-align: center;" colspan="3">
      {% else %}
      <td>{% if application.points %}{{ application.points }}{% else %}Brez{% endif %}</td>
      <td>{% if application.points_rest %}{{ application.points_rest }}{% else %}Brez{% endif %}</td>
      <td>
      {% endif %}
        {% if application.exam_grade == 0 %}
          Vrnjena prijava
        {% else %}
          {% if application.exam_grade == None and application.practice_grade == None %}
            Še ni bil ocenjen
          {% endif %}
          
          {% if application.exam.rating_type == 'OC1' or application.exam.rating_type == 'OC3' %}
            {% if application.exam_grade != None %}
              {{ application.exam_grade }}
            {% endif %}
          {% endif %}
          
          {% if application.exam.rating_type == 'OC1' %}/{% endif %}
          
          {% if application.exam.rating_type == 'OC1' or application.exam.rating_type == 'OC2' %}
            {% if application.practice_grade != None %}
              {{ application.practice_grade }}
            {% endif %}
          {% endif %}
        
        {% endif %}
      </td>
    </tr>
{% empty %}
    <tr>
      <td style="text-align: center;" colspan="4">Študent se še ni prijavil na izpit.</td>
    </tr>
{% endfor %}
  </tbody>
</table>

{% endif %}

{% endblock %}